﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XrmLibrary.Extensions
{
    public static class ObjectExtensions
    {
        /// <summary>
        /// Checks if all passed in objects are of the specified type and returns a boolean.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">The source.</param>
        /// <param name="targets">The targets.</param>
        /// <returns>True if all objects are of the same type, false if not.</returns>
        public static Boolean AreAllObjectsOfType<T>(this Object source, params Object[] targets)
        {
            if (!(source is T))
            {
                return false;
            }
            return targets.All(obj => (obj is T));
        }
    }
}
